﻿using AutoMapper;
using B.S.Material.Domain.BOM;
using B.S.Material.ErrorCode;
using B.S.Material.Read.Api.Applications.Command.FeedDetailsCommand;
using MediatR;
using SqlSugar;

namespace B.S.Material.Read.Api.Applications.Handler.FeedDetailsHandler
{
    public class FTFeedDetailsHandler : IRequestHandler<FTFeedDetailsCommand, ApiResult<List<FeedDetailss>>>
    {
        private readonly ISqlSugarClient db;
        private readonly IMapper mapper;
        public FTFeedDetailsHandler(ISqlSugarClient db, IMapper mapper)
        {
            this.db = db;
            this.mapper = mapper;
        }

        public async Task<ApiResult<List<FeedDetailss>>> Handle(FTFeedDetailsCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<FeedDetailss>> result = new ApiResult<List<FeedDetailss>>();
            result.Code = ApiEnum.显示成功;
            result.MAG = ApiEnum.显示成功.ToString();

            var list = await db.Queryable<FeedDetailss>().Where(x => x.IsDel == false && x.FeedDetailsId == request.FeedDetailsId).ToListAsync();
            result.data = list;

            return await Task.FromResult(result);
        }
    }
}
